home *** CD-ROM | disk | FTP | other *** search
/ 1st Multimedia Mac Shareware / Multimedia Shareware CD-ROM - BetaCorp.iso / StackToolsƒ / XFCNƒ / StripIt / Source Code / StripIt.p < prev   
Encoding:
Text File  |  1988-01-03  |  19.1 KB  |  619 lines  |  [TEXT/PJMM]

  1. { --------------------------------------------------------------------    }
  2. { -----|  StripIt. p                        |----------------------------------    }
  3. { --------------------------------------------------------------------    }
  4. { -----|  Eric Celeste                        |----------------------------------    }
  5. { -----|  Appropriate Technology        |----------------------------------    }
  6. { -----|  358 North Parkview            |----------------------------------    }
  7. { -----|  Columbus, Ohio 43209            |----------------------------------    }
  8. { --------------------------------------------------------------------    }
  9.  
  10. { Pascal source code for a Hypercard XFCN which strips the letters in the }
  11. { first item passed from the string passed in the second item. }
  12.  
  13. { This XFCN is not meant to be very useful, but it does serve to show those }
  14. { of us using Lightspeed Pascal how to build HyperCard XFCNs and XCMDs. }
  15. { Now the next step is for someone out there to write a shell that we can use }
  16. { for debugging these things without having to go through the LSP/ResEd/HC }
  17. { cycle over and over again. }
  18.  
  19. { Written in Lightspeed Pascal using the DA Paslib and HyperXCmd.p. }
  20. { The StripIt project should be built and saved as a code resource of the type }
  21. { XFCN and with the name “Strip”. Then that code resource should be copied }
  22. { with ResEdit into the Hypercard stack which needs to use this XFCN. }
  23.  
  24. { --------------------------------------------------------------------    }
  25. { -----| Lightspeed Pascal Project should include:        |---------------------    }
  26. { --------------------------------------------------------------------    }
  27. { -----| MacTraps                                        |---------------------    }
  28. { -----| DA Paslib                                        |---------------------    }
  29. { -----| HyperXCmd.p                                    |---------------------    }
  30. { -----| StripIt.p                                            |---------------------    }
  31. { --------------------------------------------------------------------    }
  32.  
  33. { --------------------------------------------------------------------    }
  34. { -----| Build & Save this project as:            |---------------------------    }
  35. { --------------------------------------------------------------------    }
  36. { -----|  •    Code Resource                        |---------------------------    }
  37. { -----|     Type: XFCN                            |---------------------------    }
  38. { -----|     ID: 7                                    |---------------------------    }
  39. { -----|     Name: Strip                            |---------------------------    }
  40. { --------------------------------------------------------------------    }
  41.  
  42. UNIT CoreUnit;
  43.  
  44. INTERFACE
  45.  
  46.     USES
  47.         HyperXCmd;
  48.  
  49. { When building a code resource, which this will be, LSP looks for a procedure }
  50. { called “Main” to use as the entrypoint for the code. This “Main” procedure }
  51. { must be declared here in the interface section of the unit you are compiling. }
  52. { Notice that this program is not really a program at all, since it does not have }
  53. { a “program” statement anywhere in it! }
  54.  
  55.     PROCEDURE Main (paramPtr : XCmdPtr);
  56.  
  57. IMPLEMENTATION
  58.  
  59.     PROCEDURE Main;    { declared in interface section with (paramPtr : XCmdPtr) }
  60.  
  61.         TYPE
  62.             str31 = STRING[31];        { some of the XCmdGlue functions need this type }
  63.  
  64.         VAR
  65.             theseChars : Str255;        { string holding characters we will strip out }
  66.             stringToStrip : Str255;    { string which we will strip }
  67.             result : Str255;            { this string will hold the result of the stripping }
  68.  
  69. { -------------------------------------------------------    }
  70. { -----|  XCmdGlue.inc             |---------------------------    }
  71. { -------------------------------------------------------    }
  72. { These next few procedures are from the file included in the    }
  73. { HyperCard documentation. This file defines many useful         }
  74. { procedures for writing HyperCard XCMDs and XFCNs. You        }
  75. { will notice that many of these functions are not actually used    }
  76. { by this XFCN, I have included them anyway so that you can     }
  77. { see all of what is available.                                        }
  78. {                                        You may wonder why these    }
  79. { functions are included at this particular place in the program.    }
  80. { Notice that many of the functions below use the record            }
  81. { “paramPtr” which is the XCmdPtr passed to the “Main”        }
  82. { function by HyperCard. Since this record is first declared in    }
  83. { the parameters of the “Main” function, these functions must    }
  84. { be included here, not in a library. If anyone knows of a less    }
  85. { clumbsy way of doing this, please share it with me!                }
  86. { -------------------------------------------------------    }
  87.  
  88. { XCmdGlue.inc -- Sample glue routines to call back to HyperCard.  }
  89. {  See example use in Peek.p and Flash.p}
  90. {  By Dan Winkler.  DO NOT call the author!  Contact Apple Developer }
  91. {  Support on AppleLink "MacDTS" or on MCI "MacTech".}
  92. {}
  93. {      ©Apple Computer, Inc. 1987}
  94. {    All Rights Reserved.}
  95. {}
  96.  
  97. { The Pascal code for the XCMD or XFCN should include HyperXCmd.p at}
  98. {  the beginning in the USES clause and this file at the end with the $I}
  99. {  directive.  There must be a variable named "paramPtr" that is the argument}
  100. {  that was passed into the XCMD or XFCN. All strings are Pascal strings }
  101. {  unless noted as zero-terminated strings (no length byte and the string }
  102. {  goes until a zero byte is encountered). }
  103.  
  104.  
  105.         PROCEDURE DoJsr (addr : ProcPtr);
  106.         INLINE
  107.             $205F, $4E90;
  108. { Jump subroutine to a procedure.   Pop address into A0, JSR (A0) }
  109.  
  110.         PROCEDURE SendCardMessage (msg : Str255);
  111. {  Send a HyperCard message (a command with arguments) to the current card. }
  112.         BEGIN
  113.             WITH paramPtr^ DO
  114.                 BEGIN
  115.                     inArgs[1] := ORD(@msg);
  116.                     request := xreqSendCardMessage;
  117.                     DoJsr(entryPoint);
  118.                 END;
  119.         END;
  120.  
  121.         FUNCTION EvalExpr (expr : Str255) : Handle;
  122. {  Evaluate a HyperCard expression and return the answer.  The answer is}
  123. {   a handle to a zero-terminated string. }
  124.         BEGIN
  125.             WITH paramPtr^ DO
  126.                 BEGIN
  127.                     inArgs[1] := ORD(@expr);
  128.                     request := xreqEvalExpr;
  129.                     DoJsr(entryPoint);
  130.                     EvalExpr := Handle(outArgs[1]);
  131.                 END;
  132.         END;
  133.  
  134.         FUNCTION StringLength (strPtr : Ptr) : LongInt;
  135. {  Count the characters from where strPtr points until the next zero byte. }
  136. {   Does not count the zero itself.  strPtr must be a zero-terminated string.  }
  137.         BEGIN
  138.             WITH paramPtr^ DO
  139.                 BEGIN
  140.                     inArgs[1] := ORD(strPtr);
  141.                     request := xreqStringLength;
  142.                     DoJsr(entryPoint);
  143.                     StringLength := outArgs[1];
  144.                 END;
  145.         END;
  146.  
  147.         FUNCTION StringMatch (pattern : Str255;
  148.                                         target : Ptr) : Ptr;
  149. { Perform case-insensitive match looking for pattern anywhere in}
  150. {  target, returning a pointer to first character of the first match,}
  151. {  in target or NIL if no match found.  pattern is a Pascal string,}
  152. {  and target is a zero-terminated string. }
  153.         BEGIN
  154.             WITH paramPtr^ DO
  155.                 BEGIN
  156.                     inArgs[1] := ORD(@pattern);
  157.                     inArgs[2] := ORD(target);
  158.                     request := xreqStringMatch;
  159.                     DoJsr(entryPoint);
  160.                     StringMatch := Ptr(outArgs[1]);
  161.                 END;
  162.         END;
  163.  
  164.         PROCEDURE SendHCMessage (msg : Str255);
  165. {  Send a HyperCard message (a command with arguments) to HyperCard. }
  166.         BEGIN
  167.             WITH paramPtr^ DO
  168.                 BEGIN
  169.                     inArgs[1] := ORD(@msg);
  170.                     request := xreqSendHCMessage;
  171.                     DoJsr(entryPoint);
  172.                 END;
  173.         END;
  174.  
  175.         PROCEDURE ZeroBytes (dstPtr : Ptr;
  176.                                         longCount : LongInt);
  177. {  Write zeros into memory starting at dstPtr and going for longCount }
  178. {   number of bytes. }
  179.         BEGIN
  180.             WITH paramPtr^ DO
  181.                 BEGIN
  182.                     inArgs[1] := ORD(dstPtr);
  183.                     inArgs[2] := longCount;
  184.                     request := xreqZeroBytes;
  185.                     DoJsr(entryPoint);
  186.                 END;
  187.         END;
  188.  
  189.         FUNCTION PasToZero (str : Str255) : Handle;
  190. {  Convert a Pascal string to a zero-terminated string.  Returns a handle}
  191. {   to a new zero-terminated string.  The caller must dispose the handle. }
  192.         BEGIN
  193.             WITH paramPtr^ DO
  194.                 BEGIN
  195.                     inArgs[1] := ORD(@str);
  196.                     request := xreqPasToZero;
  197.                     DoJsr(entryPoint);
  198.                     PasToZero := Handle(outArgs[1]);
  199.                 END;
  200.         END;
  201.  
  202.         PROCEDURE ZeroToPas (zeroStr : Ptr;
  203.                                         VAR pasStr : Str255);
  204. {  Fill the Pascal string with the contents of the zero-terminated}
  205. {   string.  You create the Pascal string and pass it in as a VAR }
  206. {   parameter.  Useful for converting the arguments of any XCMD to }
  207. {   Pascal strings.}
  208.         BEGIN
  209.             WITH paramPtr^ DO
  210.                 BEGIN
  211.                     inArgs[1] := ORD(zeroStr);
  212.                     inArgs[2] := ORD(@pasStr);
  213.                     request := xreqZeroToPas;
  214.                     DoJsr(entryPoint);
  215.                 END;
  216.         END;
  217.  
  218.         FUNCTION StrToLong (str : Str31) : LongInt;
  219. {  Convert a string of ASCII decimal digits to an unsigned long integer. }
  220.         BEGIN
  221.             WITH paramPtr^ DO
  222.                 BEGIN
  223.                     inArgs[1] := ORD(@str);
  224.                     request := xreqStrToLong;
  225.                     DoJsr(entryPoint);
  226.                     StrToLong := outArgs[1];
  227.                 END;
  228.         END;
  229.  
  230.         FUNCTION StrToNum (str : Str31) : LongInt;
  231. {  Convert a string of ASCII decimal digits to a signed long integer.}
  232. {   Negative sign is allowed.  }
  233.         BEGIN
  234.             WITH paramPtr^ DO
  235.                 BEGIN
  236.                     inArgs[1] := ORD(@str);
  237.                     request := xreqStrToNum;
  238.                     DoJsr(entryPoint);
  239.                     StrToNum := outArgs[1];
  240.                 END;
  241.         END;
  242.  
  243.         FUNCTION StrToBool (str : Str31) : BOOLEAN;
  244. {  Convert the Pascal strings 'true' and 'false' to booleans. }
  245.         BEGIN
  246.             WITH paramPtr^ DO
  247.                 BEGIN
  248.                     inArgs[1] := ORD(@str);
  249.                     request := xreqStrToBool;
  250.                     DoJsr(entryPoint);
  251.                     StrToBool := BOOLEAN(outArgs[1]);
  252.                 END;
  253.         END;
  254.  
  255.         FUNCTION StrToExt (str : Str31) : Extended;
  256. {  Convert a string of ASCII decimal digits to an extended long integer. }
  257.             VAR
  258.                 x : Extended;
  259.         BEGIN
  260.             WITH paramPtr^ DO
  261.                 BEGIN
  262.                     inArgs[1] := ORD(@str);
  263.                     inArgs[2] := ORD(@x);
  264.                     request := xreqStrToExt;
  265.                     DoJsr(entryPoint);
  266.                     StrToExt := x;
  267.                 END;
  268.         END;
  269.  
  270.         FUNCTION LongToStr (posNum : LongInt) : Str31;
  271. {  Convert an unsigned long integer to a Pascal string.  }
  272.             VAR
  273.                 str : Str31;
  274.         BEGIN
  275.             WITH paramPtr^ DO
  276.                 BEGIN
  277.                     inArgs[1] := posNum;
  278.                     inArgs[2] := ORD(@str);
  279.                     request := xreqLongToStr;
  280.                     DoJsr(entryPoint);
  281.                     LongToStr := str;
  282.                 END;
  283.         END;
  284.  
  285.         FUNCTION NumToStr (num : LongInt) : Str31;
  286. {  Convert a signed long integer to a Pascal string.  }
  287.             VAR
  288.                 str : Str31;
  289.         BEGIN
  290.             WITH paramPtr^ DO
  291.                 BEGIN
  292.                     inArgs[1] := num;
  293.                     inArgs[2] := ORD(@str);
  294.                     request := xreqNumToStr;
  295.                     DoJsr(entryPoint);
  296.                     NumToStr := str;
  297.                 END;
  298.         END;
  299.  
  300.         FUNCTION NumToHex (num : LongInt;
  301.                                         nDigits : INTEGER) : Str31;
  302. {  Convert an unsigned long integer to a hexadecimal number and put it}
  303. {   into a Pascal string.  }
  304.             VAR
  305.                 str : Str31;
  306.         BEGIN
  307.             WITH paramPtr^ DO
  308.                 BEGIN
  309.                     inArgs[1] := num;
  310.                     inArgs[2] := nDigits;
  311.                     inArgs[3] := ORD(@str);
  312.                     request := xreqNumToHex;
  313.                     DoJsr(entryPoint);
  314.                     NumToHex := str;
  315.                 END;
  316.         END;
  317.  
  318.         FUNCTION BoolToStr (bool : BOOLEAN) : Str31;
  319. {  Convert a boolean to 'true' or 'false'.  }
  320.             VAR
  321.                 str : Str31;
  322.         BEGIN
  323.             WITH paramPtr^ DO
  324.                 BEGIN
  325.                     inArgs[1] := LongInt(bool);
  326.                     inArgs[2] := ORD(@str);
  327.                     request := xreqBoolToStr;
  328.                     DoJsr(entryPoint);
  329.                     BoolToStr := str;
  330.                 END;
  331.         END;
  332.  
  333.         FUNCTION ExtToStr (num : Extended) : Str31;
  334. {  Convert an extended long integer to decimal digits in a string.  }
  335.             VAR
  336.                 str : Str31;
  337.         BEGIN
  338.             WITH paramPtr^ DO
  339.                 BEGIN
  340.                     inArgs[1] := ORD(@num);
  341.                     inArgs[2] := ORD(@str);
  342.                     request := xreqExtToStr;
  343.                     DoJsr(entryPoint);
  344.                     ExtToStr := str;
  345.                 END;
  346.         END;
  347.  
  348.         FUNCTION GetGlobal (globName : Str255) : Handle;
  349. {  Return a handle to a zero-terminated string containing the value of }
  350. {   the specified HyperTalk global variable.  }
  351.         BEGIN
  352.             WITH paramPtr^ DO
  353.                 BEGIN
  354.                     inArgs[1] := ORD(@globName);
  355.                     request := xreqGetGlobal;
  356.                     DoJsr(entryPoint);
  357.                     GetGlobal := Handle(outArgs[1]);
  358.                 END;
  359.         END;
  360.  
  361.         PROCEDURE SetGlobal (globName : Str255;
  362.                                         globValue : Handle);
  363. {  Set the value of the specified HyperTalk global variable to be}
  364. {   the zero-terminated string in globValue.  The contents of the }
  365. {   Handle are copied, so you must still dispose it afterwards.  }
  366.         BEGIN
  367.             WITH paramPtr^ DO
  368.                 BEGIN
  369.                     inArgs[1] := ORD(@globName);
  370.                     inArgs[2] := ORD(globValue);
  371.                     request := xreqSetGlobal;
  372.                     DoJsr(entryPoint);
  373.                 END;
  374.         END;
  375.  
  376.         FUNCTION GetFieldByName (cardFieldFlag : BOOLEAN;
  377.                                         fieldName : Str255) : Handle;
  378. {  Return a handle to a zero-terminated string containing the value of }
  379. {   field fieldName on the current card.  You must dispose the handle.  }
  380.         BEGIN
  381.             WITH paramPtr^ DO
  382.                 BEGIN
  383.                     inArgs[1] := ORD(cardFieldFlag);
  384.                     inArgs[2] := ORD(@fieldName);
  385.                     request := xreqGetFieldByName;
  386.                     DoJsr(entryPoint);
  387.                     GetFieldByName := Handle(outArgs[1]);
  388.                 END;
  389.         END;
  390.  
  391.         FUNCTION GetFieldByNum (cardFieldFlag : BOOLEAN;
  392.                                         fieldNum : INTEGER) : Handle;
  393. {  Return a handle to a zero-terminated string containing the value of }
  394. {   field fieldNum on the current card.  You must dispose the handle.  }
  395.         BEGIN
  396.             WITH paramPtr^ DO
  397.                 BEGIN
  398.                     inArgs[1] := ORD(cardFieldFlag);
  399.                     inArgs[2] := fieldNum;
  400.                     request := xreqGetFieldByNum;
  401.                     DoJsr(entryPoint);
  402.                     GetFieldByNum := Handle(outArgs[1]);
  403.                 END;
  404.         END;
  405.  
  406.         FUNCTION GetFieldByID (cardFieldFlag : BOOLEAN;
  407.                                         fieldID : INTEGER) : Handle;
  408. {  Return a handle to a zero-terminated string containing the value of }
  409. {   the field whise ID is fieldID.  You must dispose the handle.  }
  410.         BEGIN
  411.             WITH paramPtr^ DO
  412.                 BEGIN
  413.                     inArgs[1] := ORD(cardFieldFlag);
  414.                     inArgs[2] := fieldID;
  415.                     request := xreqGetFieldByID;
  416.                     DoJsr(entryPoint);
  417.                     GetFieldByID := Handle(outArgs[1]);
  418.                 END;
  419.         END;
  420.  
  421.         PROCEDURE SetFieldByName (cardFieldFlag : BOOLEAN;
  422.                                         fieldName : Str255;
  423.                                         fieldVal : Handle);
  424. {  Set the value of field fieldName to be the zero-terminated string }
  425. {   in fieldVal.  The contents of the Handle are copied, so you must }
  426. {   still dispose it afterwards.  }
  427.         BEGIN
  428.             WITH paramPtr^ DO
  429.                 BEGIN
  430.                     inArgs[1] := ORD(cardFieldFlag);
  431.                     inArgs[2] := ORD(@fieldName);
  432.                     inArgs[3] := ORD(fieldVal);
  433.                     request := xreqSetFieldByName;
  434.                     DoJsr(entryPoint);
  435.                 END;
  436.         END;
  437.  
  438.         PROCEDURE SetFieldByNum (cardFieldFlag : BOOLEAN;
  439.                                         fieldNum : INTEGER;
  440.                                         fieldVal : Handle);
  441. {  Set the value of field fieldNum to be the zero-terminated string }
  442. {   in fieldVal.  The contents of the Handle are copied, so you must }
  443. {   still dispose it afterwards.  }
  444.         BEGIN
  445.             WITH paramPtr^ DO
  446.                 BEGIN
  447.                     inArgs[1] := ORD(cardFieldFlag);
  448.                     inArgs[2] := fieldNum;
  449.                     inArgs[3] := ORD(fieldVal);
  450.                     request := xreqSetFieldByNum;
  451.                     DoJsr(entryPoint);
  452.                 END;
  453.         END;
  454.  
  455.         PROCEDURE SetFieldByID (cardFieldFlag : BOOLEAN;
  456.                                         fieldID : INTEGER;
  457.                                         fieldVal : Handle);
  458. {  Set the value of the field whose ID is fieldID to be the zero-}
  459. {   terminated string in fieldVal.  The contents of the Handle are }
  460. {   copied, so you must still dispose it afterwards.  }
  461.         BEGIN
  462.             WITH paramPtr^ DO
  463.                 BEGIN
  464.                     inArgs[1] := ORD(cardFieldFlag);
  465.                     inArgs[2] := fieldID;
  466.                     inArgs[3] := ORD(fieldVal);
  467.                     request := xreqSetFieldByID;
  468.                     DoJsr(entryPoint);
  469.                 END;
  470.         END;
  471.  
  472.         FUNCTION StringEqual (str1, str2 : Str255) : BOOLEAN;
  473. {  Return true if the two strings have the same characters.  }
  474. {   Case insensitive compare of the strings.  }
  475.         BEGIN
  476.             WITH paramPtr^ DO
  477.                 BEGIN
  478.                     inArgs[1] := ORD(@str1);
  479.                     inArgs[2] := ORD(@str2);
  480.                     request := xreqStringEqual;
  481.                     DoJsr(entryPoint);
  482.                     StringEqual := BOOLEAN(outArgs[1]);
  483.                 END;
  484.         END;
  485.  
  486.         PROCEDURE ReturnToPas (zeroStr : Ptr;
  487.                                         VAR pasStr : Str255);
  488. {  zeroStr points into a zero-terminated string.  Collect the }
  489. {   characters from there to the next carriage Return and return }
  490. {   them in the Pascal string pasStr.  If a Return is not found, }
  491. {   collect chars until the end of the string. }
  492.         BEGIN
  493.             WITH paramPtr^ DO
  494.                 BEGIN
  495.                     inArgs[1] := ORD(zeroStr);
  496.                     inArgs[2] := ORD(@pasStr);
  497.                     request := xreqReturnToPas;
  498.                     DoJsr(entryPoint);
  499.                 END;
  500.         END;
  501.  
  502.         PROCEDURE ScanToReturn (VAR scanPtr : Ptr);
  503. {  Move the pointer scanPtr along a zero-terminated }
  504. {   string until it points at a Return character}
  505. {   or a zero byte.  }
  506.         BEGIN
  507.             WITH paramPtr^ DO
  508.                 BEGIN
  509.                     inArgs[1] := ORD(@scanPtr);
  510.                     request := xreqScanToReturn;
  511.                     DoJsr(entryPoint);
  512.                 END;
  513.         END;
  514.  
  515.         PROCEDURE ScanToZero (VAR scanPtr : Ptr);
  516. {  Move the pointer scanPtr along a zero-terminated }
  517. {   string until it points at a zero byte.  }
  518.         BEGIN
  519.             WITH paramPtr^ DO
  520.                 BEGIN
  521.                     inArgs[1] := ORD(@scanPtr);
  522.                     request := xreqScanToZero;
  523.                     DoJsr(entryPoint);
  524.                 END;
  525.         END;
  526.  
  527. { -------------------------------------------------------    }
  528. { -----|  End of XCmdGlue.inc     |---------------------------    }
  529. { -------------------------------------------------------    }
  530.  
  531.  
  532. { -------------------------------------------------------    }
  533. { -----|  Strip Procedure         |---------------------------    }
  534. { -------------------------------------------------------    }
  535. { This is the heart of the HyperCard Strip function. Note that    }
  536. { no parameters are passed into it since what it needs is         }
  537. { already global to this procedure, having been declared up at    }
  538. { the start of “Main”.                                                 }
  539. {                                Strip takes the characters in the    }
  540. { string that was the first parameter from HyperCard, now        }
  541. { called theseCharacters, and creates a set that includes only    }
  542. { these characters. It then steps through what was the second    }
  543. { parameter from HyperCard, now called stringToStrip, and        }
  544. { checks to see if each character in this string is in the set of    }
  545. { characters it is to strip. If a character is not in that set,        }
  546. { then the procedure concatinates that character to the result    }
  547. { that will eventually be passed back to HyperCard. Since the    }
  548. { result will never have a character concatinated that is in the    }
  549. { set being stripped, the result will be devoid of the characters    }
  550. { in the first parameter from HyperCard.                            }
  551. { -------------------------------------------------------    }
  552.  
  553.         PROCEDURE Strip;
  554.  
  555.             TYPE
  556.                 charset = SET OF char;                    { this is what it sounds like }
  557.  
  558.             VAR
  559.                 stripset : charset;                        { this set will hold the characters to strip }
  560.                 numberOfChars, position : Integer;        { hold the length and place in strings }
  561.                 aChar : char;                                { temporary holder for individual characters }
  562.  
  563.         BEGIN        { start of the Strip procedure }
  564.  
  565.         { start with an empty set }
  566.             stripset := [];
  567.  
  568.         { add the characters we want to strip to the set }
  569.             numberOfChars := Length(theseChars);
  570.             position := 1;
  571.             WHILE position <= numberOfChars DO
  572.                 BEGIN
  573.                     aChar := Copy(theseChars, position, 1);
  574.                     stripset := stripset + [aChar];
  575.                     position := position + 1;
  576.                 END;
  577.  
  578.         { and finally, copy the characters not to be stripped to the result }
  579.             result := '';
  580.             numberOfChars := Length(stringToStrip);
  581.             position := 1;
  582.             WHILE position <= numberOfChars DO
  583.                 BEGIN
  584.                     aChar := Copy(stringToStrip, position, 1);
  585.                     IF aChar IN stripset THEN
  586.                         BEGIN
  587.                 { in this case we skip this letter altogether }
  588.                         END
  589.                     ELSE
  590.                         BEGIN
  591.                 { in this case we add this letter to the result }
  592.                             result := Concat(result, aChar);
  593.                         END;
  594.                     position := position + 1;
  595.                 END;
  596.  
  597.         END;        { end of the Strip procedure }
  598.  
  599. { -------------------------------------------------------    }
  600. { -----|  End of Strip Procedure |---------------------------    }
  601. { -------------------------------------------------------    }
  602.  
  603.  
  604.     BEGIN        { main (the entrypoint) }
  605.  
  606.         { first convert the parameters passed from HyperCard into Pascal-type strings }
  607.         ZeroToPas(paramPtr^.Params[1]^, theseChars);
  608.         ZeroToPas(paramPtr^.Params[2]^, stringToStrip);
  609.  
  610.         { then do the stripping }
  611.         Strip;        { see the function above for the details of how this is done }
  612.  
  613.         { and finally put the result where HyperCard will be able to find it }
  614.         paramPtr^.returnValue := PasToZero(result);
  615.  
  616.     END;            { main (the entrypoint) }
  617.  
  618.  
  619. END.            { CoreUnit }